<template>
	<view class="page" :style="themeColor">
		<view class="flex flex-direction flex-wrap align-stretch justify-center benben-position-layout flex my_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-stretch justify-between my_fd0_0'>
				<view class='flex flex-wrap align-center my_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  balanceDetail_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-center'>
					<text class='my_fd0_0_c1_c0'>会员权益</text>
				</view>
				<view class="my_fd0_0_c0"></view>
			</view>
			

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#F35D2A"></u-loading>
			<view>加载中</view>
		</view>
		<template v-else>
			<view class="member_info">
				<view class="member_user">
					<view class="user">
						<view class="user_img">
							<image :src="userInfo.head_img" mode="aspectFill"></image>
						</view>
						<view class="user_name">
							<view class="user_name_1">{{userInfo.user_nickname}}</view>
							<view class="user_name_2" v-if="userInfo.is_vip == 0">您当前未开通会员</view>
							<view class="user_name_2" v-else>有效期：{{userInfo.vip_last_time}}</view>
						</view>
					</view>
					<view class="tips" v-if="userInfo.is_vip == 0">开通会员享更多优惠</view>
					<view class="tips" v-else>专属会员标识，可续费延长</view>
				</view>
				
				<view class="member_agreement">
					<view class="rule_info">
						<scroll-view scroll-x="true">
							<template v-for="(item, index) in ruleList">
								<template v-if="rule_id != item.id">
									<view class="rule_item" :key="index" @tap.stop="selectRule(item.id, item.money, item.content)">
										<view class="item_title">{{item.name}}</view>
										<view class="item_price">
											<text class="item_price_1">¥</text>
											<text class="item_price_2">{{item.money}}</text>
										</view>
										<view class="item_price_decoration">¥{{item.original_money}}</view>
									</view>
								</template>
								<template v-else>
									<view class="rule_item_active" :key="index" @tap.stop="selectRule(item.id, item.money, item.content)">
										<view class="item_title_active">{{item.name}}</view>
										<view class="item_price_active">
											<text class="item_price_1_active">¥</text>
											<text class="item_price_2_active">{{item.money}}</text>
										</view>
										<view class="item_price_decoration_active">¥{{item.original_money}}</view>
									</view>
								</template>
							</template>
						</scroll-view>
					</view>
					
					<view class="equity">
						<view class="equity_title">
							<view class="equity_title_1"></view>
							<view class="equity_title_2">会员权益</view>
						</view>
						<view class="equity_tips">
							<u-parse :html="rule_content"></u-parse>
						</view>
					</view>
				</view>
			</view>
			
			<view class="sign_btn" @tap.stop="buyNow">立即购买</view>
		</template>
		<view style="height: 120rpx;"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				"content": '1111',
				"userInfo": {
					"user_money": 0
				},
				"catch_sign_in_time": "", //连续签到次数
				"is_catch_sign_in": "", //是否连续签到：0=否，1=是
				"is_today_sign_in": "", //今天是否签到“0=否，1=是
				"sign_success_num": 0,  // 成功的积分
				"ruleList": [], // 规则列表
				"rule_id": "-1",
				"rule_money": "",
				"rule_content": "",
				"show": false,
				"isShow": false,
				"is_submit": false,
				
			}
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
		},
		onLoad() {
			this.getSignList();
		},
		onShow() {
			this.getData();
		},
		methods: {
			// 会员规则列表  post65ab645369bea
			getSignList() {
				this.$api.post(global.apiUrls.post65ab645369bea, {

				}).then(res => {
					console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.ruleList = res.data.data;
						if (this.ruleList.length > 0) {
							this.rule_id = this.ruleList[0].id;
							this.rule_money = this.ruleList[0].money;
							this.rule_content = this.ruleList[0].content;
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			selectRule(id, money, content) {
				this.rule_id = id;
				this.rule_money = money;
				this.rule_content = content;
			},
			
			// 获取会员资料  post5c78c4772da97
			getData() {
				this.$api.post(global.apiUrls.post5c78c4772da97, {

				}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						this.userInfo = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			buyNow() {
				if (this.is_submit) return;
				this.is_submit = true;
				this.$api.post(global.apiUrls.post65ab6466d9ee8, {
					rule_id: this.rule_id,
					pay_way: 'wxpay'
				}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						this.is_submit = false;
						uni.navigateTo({
							url: '/pages/xitongs/member/memberPay?order_sn=' + res.data.data.order_sn + '&money=' + this.rule_money
						})
					} else {
						this.is_submit = false;
						this.$message.info(res.data.msg);
					}
				})
				
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.member_info {
		padding: 42rpx 0rpx 0;
		.member_user {
			width: 702rpx;
			height: 341rpx;
			background: url(https://yongzhixing.niurenjianzhan.com/uploads/mini/507.png) no-repeat;
			background-size: 100% 100%;
			padding: 43rpx 43rpx 0;
			margin: 0 24rpx;
			.user {
				display: flex;
			}
			.user_img {
				width: 94rpx;
				height: 94rpx;
				margin-right: 20rpx;
				image {
					width: 100%;
					height: 100%;
				}
			}
			.user_name {
				width: calc(100% - 114rpx);
				.user_name_1 {
					font-size: 32rpx;
					text-overflow: ellipsis;
					overflow: hidden;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 1; /* 这里是超出几行省略 */
				}
				.user_name_2 {
					margin-top: 16rpx;
					color: #FF7F00;
					font-size: 24rpx;
					font-weight: 500;
				}
			}
		}
		.tips {
			color: #8E5535;
			font-size: 24rpx;
			margin-top: 42rpx;
		}
		.member_agreement {
			padding: 64rpx 0rpx 0;
			transform: translateY(-100rpx);
			width: 100%;
			min-height: 700rpx;
			background: url(https://yongzhixing.niurenjianzhan.com/uploads/mini/508.png) no-repeat;
			background-size: 100% 100%;
			.rule_info {
				scroll-view {
					padding: 0 24rpx;
					width: 100%;
					white-space: nowrap;
					.rule_item {
						display: inline-block;
						width: 202rpx;
						height: 254rpx;
						background: #FFFFFF;
						box-shadow: 0px 10rpx 30rpx 1px rgba(0,0,0,0.1);
						border-radius: 16rpx;
						margin: 0 12rpx 36rpx;
						padding: 40rpx 0 0;
						text-align: center;
						border: 4rpx solid #FFFFFF;
						.item_title {
							font-size: 32rpx;
							font-weight: bold;
							margin-bottom: 28rpx;
						}
						.item_price {
							font-weight: bold;
							.item_price_1 {
								font-size: 32rpx;
							}
							.item_price_2 {
								font-size: 44rpx;
							}
						}
						.item_price_decoration {
							color: #DBAA3A;
							font-size: 24rpx;
							margin-top: 24rpx;
							text-decoration: line-through;
						}
					}
					.rule_item_active {
						border: 4rpx solid #FECF6D;
						display: inline-block;
						width: 202rpx;
						height: 254rpx;
						background: #FFFBF7;
						box-shadow: 0px 10rpx 30rpx 1px rgba(219,170,58,0.2);
						border-radius: 16rpx;
						margin: 0 12rpx 36rpx;
						padding: 40rpx 0 0;
						text-align: center;
						.item_title_active {
							color: #774B17;
							font-size: 32rpx;
							font-weight: bold;
							margin-bottom: 28rpx;
						}
						.item_price_active {
							font-weight: bold;
							color: #774B17;
							.item_price_1_active {
								font-size: 32rpx;
							}
							.item_price_2_active {
								font-size: 44rpx;
							}
						}
						.item_price_decoration_active {
							color: #DBAA3A;
							font-size: 24rpx;
							margin-top: 24rpx;
							text-decoration: line-through;
						}
					}
				}
			}
		}
		.equity {
			padding: 32rpx 20rpx;
			background: #F6F6F6;
			border-radius: 24rpx;
			margin: 0 32rpx;
			.equity_title {
				display: flex;
				align-items: center;
				.equity_title_1 {
					width: 8rpx;
					height: 30rpx;
					background: #774B17;
					border-radius: 4rpx;
					margin-right: 16rpx;
				}
				.equity_title_2 {
					color: #774B17;
					font-size: 32rpx;
				}
			}
			.equity_tips {
				margin-top: 24rpx;
				font-size: 24rpx;
				color: #999;
			}
		}
	}
	.agreement_icon {
		width: 32rpx;
		height: 32rpx;
		margin-left: 24rpx;
	}
	.sign_bg {
		padding: 140rpx 80rpx 0;
		image {
			width: 591rpx;
			height: 370rpx;
		}
	}

	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.rect {
		width: 550rpx;
		height: 400rpx;
		background-color: #fff;
		border-radius: 24rpx;
		text-align: center;
		position: relative;
		padding-top: 140rpx;
		.rect_img {
			width: 375rpx;
			height: 236rpx;
			position: absolute;
			top: -110rpx;
			left: 88rpx;
		}
		.rect_name1 {
			font-weight: 500;
			font-size: 32rpx;
			margin-bottom: 18rpx;
			color: #000;
			font-weight: 500;
		}
		.rect_name2 {
			font-size: 28rpx;
			color: #999;
		}
		.rect_btn {
			width: 354rpx;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			background: #F35D2A;
			border-radius: 50rpx;
			font-size: 32rpx;
			color: #fff;
			margin: 40rpx auto 0;
		}
	}
	.sign_content {
		background: #fff;
		border-radius: 24rpx;
		margin: -76rpx 32rpx 0;
	}
	.learn_money {
		padding: 70rpx 40rpx 40rpx;
		display: flex;

		.learn_money_title {
			font-weight: 500;
			font-size: 32rpx;
			color: #333333;
			margin-bottom: 16rpx;
			transform: translateY(20rpx);
		}

		.learn_money_num {
			font-weight: bold;
			font-size: 64rpx;
			color: #FFC558;
		}
	}

	.sign_tips {
		padding: 0 32rpx;

		.sign_tips_x {
			background: #fff;
			padding: 32rpx 32rpx 40rpx;
			border-radius: 24rpx;

			.sign_tips_title {
				font-size: 32rpx;
				font-weight: 500;
				color: #333;
			}

			.sign_tips_content {
				margin-top: 32rpx;
				font-size: 28rpx;
				font-weight: 400;
				color: #666666;
				line-height: 0rpx;
			}
		}
	}
	.sign_btn {
		width: 686rpx;
		height: 80rpx;
		background: #F35D2A;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		text-align: center;
		line-height: 80rpx;
		color: #fff;
		font-size: 32rpx;
		position: absolute;
		left: 32rpx;
		bottom: 38rpx;
	}
	
	.sign_bt2 {
		width: 638rpx;
		height: 88rpx;
		background: #BFBFBF;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		text-align: center;
		line-height: 88rpx;
		color: #fff;
		font-size: 32rpx;
		margin: 88rpx auto 0;
	}
	.days {

		margin-bottom: 32rpx;

		.days_list {
			padding: 0rpx 24rpx 40rpx;

			.days_list_title {
				font-weight: 500;
				font-size: 28rpx;
				text-align: center;
				margin-bottom: 40rpx;
				color: #666666;
			}

			
		}

		.days_list_content {
			overflow: hidden;

			.item {
				float: left;
				margin-right: 26rpx;
				width: 136rpx;
				height: 166rpx;
				background: linear-gradient(180deg, #FFA474 0%, #FC3045 100%);
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				text-align: center;
				padding-top: 16rpx;
				color: #fff;
				margin-bottom: 32rpx;

				.item_day {
					font-size: 24rpx;
				}

				.item_img {
					width: 56rpx;
					height: 56rpx;
					margin: 12rpx auto 8rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.item_num {
					font-size: 20rpx;
				}
			}

			.item2 {
				float: left;
				margin-right: 26rpx;
				width: 136rpx;
				height: 166rpx;
				background: #F5F6FA;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				text-align: center;
				padding-top: 16rpx;
				margin-bottom: 32rpx;

				.item_day {
					font-size: 24rpx;
					color: #333;
				}

				.item_img {
					width: 56rpx;
					height: 56rpx;
					margin: 12rpx auto 8rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.item_num {
					font-size: 20rpx;
					color: #999;
				}
			}

			.item3 {
				float: left;
				width: 84rpx;
				height: 128rpx;
				background: #F5F6FA;
				border-radius: 8rpx;
				text-align: center;
				padding: 24rpx 0rpx 0;
				margin-right: 8rpx;
				text-align: center;
				.sign_icon {
					width: 50rpx;
					height: 50rpx;
					position: absolute;
					left: 0;
					top: 0;
				}
				.item3_left {
					text-align: center;
					.item3_left1 {
						font-size: 24rpx;
						color: #999;
						margin-bottom: 5rpx;
					}

					.item3_left2 {
						font-size: 20rpx;
						color: #999;
					}
				}

				.item3_right {
					width: 44rpx;
					height: 44rpx;
					margin: 0 auto 10rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
			}

			.item4 {
				float: left;
				width: 84rpx;
				height: 128rpx;
				background: linear-gradient(180deg, #FFAE84 0%, #FC3346 100%);
				border-radius: 8rpx;
				text-align: center;
				padding: 24rpx 0rpx 0;
				margin-right: 8rpx;
				text-align: center;
				position: relative;
				.sign_icon {
					width: 50rpx;
					height: 50rpx;
					position: absolute;
					left: 0;
					top: 0;
				}
				.item3_left {
					text-align: center;
					.item3_left1 {
						font-size: 24rpx;
						color: #999;
						margin-bottom: 5rpx;
					}
				
					.item3_left2 {
						font-size: 20rpx;
						color: #999;
					}
				}
				
				.item3_right {
					width: 44rpx;
					height: 44rpx;
					margin: 0 auto 10rpx;
					image {
						width: 100%;
						height: 100%;
					}
				}
			}

			.item:nth-child(4n+4) {
				margin-right: 0;
			}

			.item2:nth-child(4n+4) {
				margin-right: 0;
			}
		}
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: url(https://yongzhixing.niurenjianzhan.com/uploads/mini/506.png) no-repeat, rgba(248, 248, 248, 1);
		background-size: 100% auto !important;
		// background: #FFFFFF;
	}

	.my_flex_0 {
		background: url(https://yongzhixing.niurenjianzhan.com/uploads/mini/506.png) no-repeat, transparent;
		background-size: 100% !important;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.balanceDetail_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #fff;
	}

	.my_fd0_0_c2_c0 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.my_fd0_0_c2 {
		padding: 0rpx 0rpx 0rpx 0rpx;
		width: 150rpx;
	}

	.my_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #FFFFFF;
		line-height: 50rpx;
	}

	.my_fd0_0_c0 {
		width: 150rpx;
	}

	.my_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.my_fd1_1_c3_c1 {
		padding: 16rpx 0rpx 0rpx 0rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #323232;
	}

	.my_fd1_1_c3_c0 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.my_fd1_1_c2_c1 {
		padding: 16rpx 0rpx 0rpx 0rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #323232;
	}

	.my_fd1_1_c2_c0 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.my_fd1_1_c1_c1 {
		padding: 16rpx 0rpx 0rpx 0rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #323232;
	}

	.my_fd1_1_c1_c0 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.my_fd1_1_c0_c1 {
		padding: 16rpx 0rpx 0rpx 0rpx;
		font-size: 24rpx;
		font-weight: 500;
		color: #323232;
	}

	.my_fd1_1_c0_c0 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}
</style>
